package com.eg;import java.lang.reflect.Constructor;import java.lang.reflect.InvocationTargetException;/** * @email 99723251@qq.com * @author: zhangyangtao * @date: 2019/6/13 * @time: 12:32 AM */public enum EnumSingleton {    INSTANCE;    // 枚举能够绝对有效的防止实例化多次,和防止反射和序列化破解    public void add() {        System.out.println("add方法...");    }    public static void main(String[] args) throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {        EnumSingleton instance1 = EnumSingleton.INSTANCE;        EnumSingleton instance2 = EnumSingleton.INSTANCE;        System.out.println(instance1 == instance2);        Constructor<EnumSingleton> declaredConstructor = EnumSingleton.class.getDeclaredConstructor();        declaredConstructor.setAccessible(true);        EnumSingleton v3 = declaredConstructor.newInstance();        System.out.println(v3==instance1);    }}